/*******************************************************************************
 * Copyright (c) 2008, 2009 Fabio Mauro - Alberto Terraneo.
 * Permission is granted to copy, distribute and/or modify this document
 * under the terms of the GNU Free Documentation License, Version 1.2
 * or any later version published by the Free Software Foundation.
 *     
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied 
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
 * See the GNU Free Documentation License for more details.
 *     
 * You should have received a copy of the GNU Free Documentation 
 * License along with this distribution; if not, send a email to authors:
 * aterraneo <at> users.sourceforge.net
 * bigmoby09 <at> users.sourceforge.net
 *******************************************************************************/
package it.blueocean.acanto.model.constants;

import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;

public enum Provincia
{
	NULL(""),AG("AGRIGENTO"), AL("ALESSANDRIA"), AN("ANCONA"), AR("AREZZO"), AP("ASCOLI PICENO"), AT("ASTI"), AV("AVELLINO"), BA("BARI"), BL("BELLUNO"), BN("BENEVENTO"), BG("BERGAMO"), BI(
		"BIELLA"), BO("BOLOGNA"), BZ("BOLZANO - BOZEN"), BS("BRESCIA"), BR("BRINDISI"), CA("CAGLIARI"), CL("CALTANISSETTA"), CB("CAMPOBASSO"), CI("CARBONIA-IGLESIAS"), CE(
		"CASERTA"), CT("CATANIA"), CZ("CATANZARO"), CH("CHIETI"), CO("COMO"), CS("COSENZA"), CR("CREMONA"), KR("CROTONE"), CN("CUNEO"), EN("ENNA"), FE("FERRARA"), FI("FIRENZE"), FG(
		"FOGGIA"), FC("FORLI-CESENA"), FR("FROSINONE"), GE("GENOVA"), GO("GORIZIA"), GR("GROSSETO"), IM("IMPERIA"), IS("ISERNIA"), AQ("L'AQUILA"), SP("LA SPEZIA"), LT("LATINA"), LE(
		"LECCE"), LC("LECCO"), LI("LIVORNO"), LO("LODI"), LU("LUCCA"), MC("MACERATA"), MN("MANTOVA"), MS("MASSA-CARRARA"), MT("MATERA"), VS("MEDIO CAMPIDANO"), ME("MESSINA"), MI(
		"MILANO"), MO("MODENA"), NA("NAPOLI"), NO("NOVARA"), NU("NUORO"), OG("OGLIASTRA"), OT("OLBIA-TEMPIO"), OR("ORISTANO"), PD("PADOVA"), PA("PALERMO"), PR("PARMA"), PV("PAVIA"), PG(
		"PERUGIA"), PU("PESARO URBINO"), PE("PESCARA"), PC("PIACENZA"), PI("PISA"), PT("PISTOIA"), PN("PORDENONE"), PZ("POTENZA"), PO("PRATO"), RG("RAGUSA"), RA("RAVENNA"), RC(
		"REGGIO DI CALABRIA"), RE("REGGIO NELL'EMILIA"), RI("RIETI"), RN("RIMINI"), RM("ROMA"), RO("ROVIGO"), SA("SALERNO"), SS("SASSARI"), SV("SAVONA"), SI("SIENA"), SR(
		"SIRACUSA"), SO("SONDRIO"), TA("TARANTO"), TE("TERAMO"), TR("TERNI"), TO("TORINO"), TP("TRAPANI"), TN("TRENTO"), TV("TREVISO"), TS("TRIESTE"), UD("UDINE"), AO(
		"VALLE D'AOSTA"), VA("VARESE"), VE("VENEZIA"), VB("VERBANO-CUSIO-OSSOLA"), VC("VERCELLI"), VR("VERONA"), VV("VIBO VALENTIA"), VI("VICENZA"), VT("VITERBO");

	private final String valore;

	Provincia(String valore)
	{
		this.valore = valore;
	}

	public static List<Provincia> getListProvinciaEnum()
	{
		return new ArrayList<Provincia>(Collections.synchronizedSet(EnumSet.allOf(Provincia.class)));
	}

	public String getValore()
	{
		return valore;
	}
	
	public static int getIndex(String provinciaValue)
	{
		List<Provincia> list = getListProvinciaEnum();
		for (Provincia item : list)
		{
			if(item.valore.equalsIgnoreCase(provinciaValue))
				return item.ordinal();
		}
		return -1;
	}
	
	public static Provincia getFromValue(String provinciaValue)
	{
		List<Provincia> list = getListProvinciaEnum();
		for (Provincia item : list)
		{
			if(item.valore.equalsIgnoreCase(provinciaValue))
				return item;
		}
		return null;
	}

	public static List<String> getListStringProvinciaEnumValues()
	{
		List<String> resultList = new ArrayList<String>();
		List<Provincia> list = Provincia.getListProvinciaEnum();
		for (Provincia provinciaEnum : list)
		{
			resultList.add(provinciaEnum.getValore());
		}
		return resultList;
	}
}
